package com.jilian.powerstation.modul.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jilian.powerstation.R;
import com.jilian.powerstation.common.dto.PowerDto;
import com.jilian.powerstation.listener.CustomItemClickListener;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public class ErrorsListAdapter extends RecyclerView.Adapter<ErrorsListAdapter.ViewHolder> {

    private List<String> mDatas;
    private Context mContext;


    public ErrorsListAdapter(List<String> mDatas, Context context) {
        this.mDatas = mDatas;
        this.mContext = context;

    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.item_errors, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;


    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        holder.tvName.setText(mDatas.get(position));
        if (position == mDatas.size() - 1) {
            holder.vLine.setVisibility(View.GONE);
        } else {
            holder.vLine.setVisibility(View.VISIBLE);
        }

    }

    @Override
    public int getItemCount() {
        return mDatas.size();
    }


    class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tvName;
        private View vLine;


        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            vLine = (View) itemView.findViewById(R.id.v_line);
            tvName = itemView.findViewById(R.id.tv_name);

        }
    }
}
